<?php
header("Content-type: text/html; charset=utf-8");
set_time_limit (0);
$link = mysqli_connect('127.0.0.1','root','','sku');
$res = mysqli_query($link, 'set names utf8');
$res = mysqli_query($link, 'select * from skulist where img_status=0 ');
while ($row = mysqli_fetch_assoc($res)){
    $data[] = $row;
}
include 'function.php';
foreach ($data as $v){
    $key = $v["老SKU"];
    $str = $v["产品描述1"];
    $str = strip_tags($str);
    foreach ($v as $vk=>$vv){
        if(strstr($vk, '图片')){
            if(empty($vv)) continue;
            $na = explode($key, $vv);
            $name = $key.$na[1];
            $url = './img/'.$key.'/'.$name;
            getImage($vv,'./img/'.$key,$name);
            //$sql = "update skulist set `$vk`='$url' where `老SKU`='$key' ";
            //mysqli_query($link, $sql);
        }
    }
    $sql = "update skulist set `img_status`=1 where `老SKU`='$key' ";
    mysqli_query($link, $sql);
}
echo 'success';